﻿namespace ServerSide.Common
{
    //返回结果集
    public class Result<T> where T : class
    {
        //200:successs;501:failed
        private string? _code;
        private string? _mes;
        private T? _data;
        public string Code { get { return _code; } set { _code = value; } }
        public string Message { get { return _mes; } set { _mes = value; } }
        public T Data { get { return _data; } set { _data = value; } }
        //成功返回结果
        public static Result<T> Success(T obj)
        {
            Result<T> result = new Result<T>()
            {
                Code = "200",
                Data = obj
            };
            return result;
        }
        //失败返回结果
        public static  Result<T> Error(string code,string message)
        {
            Result<T> result = new Result<T>() {
                Code = code,
                Message = message
            };
            return result;
        }
    }
}
